<?php
declare (strict_types=1);

namespace app\api\controller;

use app\common\model\Assets;
use app\common\model\Account as AccountModel;
use think\facade\View;
use think\response\Json;

class Account extends Base
{

    public function index(): Json
    {

        $list = Assets::getFields(3);
        $result = [];
        foreach ($list as $key => $v) {
            $result[] = [
                'title' => $v,
                'account' => $key,
                'balance' => $this->user->assets->$key
            ];
        }
        return json(['code' => 1, 'msg' => 'success', 'result' => $result]);
    }


    public function getList(): Json
    {
        $param = $this->request->param();

        $map = ['type' => $param['type'], 'uid' => $this->user->id];

        return json(AccountModel::getPageList($map, 'id,intro,amount,after,create_time,fx', $param['page'], 20, false, ['user']));
    }
}

